# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python


class Recipe(recipe.Recipe):
    name = 'libtheora'
    version = '1.1.1'
    licenses = [{License.BSD: ['COPYING'], License.Misc: ['LICENSE']}]
    stype = SourceType.TARBALL
    url = 'xiph://theora/%(name)s-%(version)s.tar.bz2'
    tarball_checksum = 'b6ae1ee2fa3d42ac489287d3ec34c5885730b1296f0801ae577a35193d3affbc'
    deps = ['libogg', 'libvorbis']
    allow_parallel_build = False
    patches = [
        'libtheora/0004-examples-Don-t-use-png_sizeof.patch',
        'libtheora/0006-Fix-cross-compilation-build.patch',
    ]
    configure_options = ' --disable-spec --disable-examples'

    files_libs = ['libtheora', 'libtheoradec', 'libtheoraenc']
    files_bins = ['dvconnect', 'encodedv', 'dubdv']
    files_devel = ['include/theora', 'lib/pkgconfig/theora.pc',
                   'lib/pkgconfig/theoraenc.pc', 'lib/pkgconfig/theoradec.pc']

    def prepare(self):
        if self.config.platform != Platform.WINDOWS:
            # Don't build documentation even if doxygen is available
            self.autoreconf = True
            self.autoreconf_sh = 'NOCONFIGURE=1 ./autogen.sh'
            self.configure_options += ' --disable-doc'
            self.patches += [
                'libtheora/0001-Add-option-to-disable-doc.patch',
                'libtheora/0003-Use-our-automake-version-and-not-an-older-one.patch',
                'libtheora/0005-build-allow-skipping-configure-in-autogen.sh.patch',
            ]
        if self.config.target_platform == Platform.IOS:
            self.patches += ['libtheora/0007-Don-t-use-fforce-addr.patch']
        elif self.config.target_platform == Platform.DARWIN:
            self.patches += ['libtheora/0007-Don-t-use-fforce-addr.patch']
